package com.atguigu.service_edu.controller;


import com.atguigu.commonutils.R;
import com.atguigu.service_edu.client.VodClient;
import com.atguigu.service_edu.entity.EduVideo;
import com.atguigu.service_edu.service.EduVideoService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author clark
 * @since 2020-04-10
 */
@RestController
@CrossOrigin
@RequestMapping("/eduservice/video")
public class EduVideoController {

    @Autowired
    private EduVideoService eduVideoService;
    @Autowired
    private VodClient vodClient;

    @ApiOperation(value = "添加章节")
    @PostMapping("/addVideo")
    private R addVideo(@RequestBody  EduVideo eduVideo){

        eduVideoService.save(eduVideo);
        return R.ok();
    }

    @ApiOperation(value = "根据id获取章节")
    @GetMapping("/getVideo/{id}")
    private R getVideo(@PathVariable String id){
        EduVideo eduVideo = eduVideoService.getById(id);
        return R.ok().data("eduVideo",eduVideo);
    }

    @ApiOperation(value = "根据id更新章节")
    @PutMapping("/updateVideo")
    private R updateVideo(@RequestBody  EduVideo eduVideo){
        eduVideoService.updateById(eduVideo);
        return R.ok();
    }

    @ApiOperation(value = "根据Id删除章节")
    @DeleteMapping("/deleteVideo/{id}")
    private R deleteVideo(@PathVariable String id){

        eduVideoService.removeVideo(id);
        return R.ok();
    }











}

